package com.yst.metho.web.application.pointage;

import java.util.ArrayList;
import java.util.Calendar;

import nextapp.echo2.app.Column;
import nextapp.echo2.app.Extent;
import nextapp.echo2.app.Grid;
import nextapp.echo2.app.Insets;
import nextapp.echo2.app.Label;
import nextapp.echo2.app.SelectField;

import com.yst.metho.web.application.utils.GenericModel;

/**
 * Vue qui permet de selectionner la semaine pour laquelle l'utilisateur veut
 * generer son rapport hebdomadaire.
 * 
 * @author perso
 * 
 */
public class SelectYearPane extends Column
{
	private SelectField mSelectedYear;

	public SelectYearPane()
	{
		super();
		setCellSpacing(new Extent(10));
		setInsets(new Insets(10));
		Grid headerGrid = new Grid();
		headerGrid.setInsets(new Insets(0, 2));
		add(headerGrid);
		Label label;
		label = new Label("Annee : ");
		headerGrid.add(label);

		mSelectedYear = new SelectField();
		headerGrid.add(mSelectedYear);
		ArrayList lst = new ArrayList();
		int year = Calendar.getInstance().get(Calendar.YEAR);
		lst.add(new Integer(year - 1));
		lst.add(new Integer(year));
		lst.add(new Integer(year + 1));
		mSelectedYear.setModel(new GenericModel(lst));
	}

	public int getSelectedDay()
	{
		return Integer.parseInt(mSelectedYear.getSelectedItem().toString());
	}
}
